package com.suineg.pms.entity.fee;


import java.util.Date;
import java.util.List;
import java.util.Set;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

import com.google.common.collect.Lists;
import com.suineg.pms.entity.IdEntity;
import com.suineg.pms.entity.User;
import com.suineg.pms.entity.commons.SystemInfo;

/**
 * 交费基准 实体类
 *@author Suine
 */
@Entity
@Table(name = "pms_fee_scale")
public class FeeScal extends IdEntity{
	/** 基准名 */
	private String name;
	/** 类型 */
	private SystemInfo type;
	/** 发布单位  */
	private String releaseUnit;
	/** 收费周期 */
	private Double cycle;
	/** 价格 */
	private Double money;
	/** 单位 */
	private String unit;
	/** 备注 */
	private String memo;
	/** 操作人 */
	private User opuser;
	/** 操作时间 */
	private Date opdate;
	
	/** 方案与基准中间表 */
	private Set<PlanScal> planScal;
	@OneToMany(fetch = FetchType.LAZY,mappedBy = "feeScal")
	public Set<PlanScal> getPlanScal() {
		return planScal;
	}
	public void setPlanScal(Set<PlanScal> planScal) {
		this.planScal = planScal;
	}
	/** 收费方案 */
	private List<FeePlan> feePlanList = Lists.newArrayList();
	
	@ManyToMany
	@JoinTable(name = "pms_plan_scale",joinColumns = {@JoinColumn(name = "scale_id")},inverseJoinColumns = {@JoinColumn(name = "plan_id")})
	@Fetch(FetchMode.SUBSELECT)
	// 集合按id排序
	@OrderBy("id ASC")
	// 缓存策略
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
	public List<FeePlan> getFeePlanList() {
		return feePlanList;
	}
	public void setFeePlanList(List<FeePlan> feePlanList) {
		this.feePlanList = feePlanList;
	}
	@ManyToOne(fetch = FetchType.LAZY)
	public SystemInfo getType() {
		return type;
	}
	public void setType(SystemInfo type) {
		this.type = type;
	}
	public String getReleaseUnit() {
		return releaseUnit;
	}
	public void setReleaseUnit(String releaseUnit) {
		this.releaseUnit = releaseUnit;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public Double getCycle() {
		return cycle;
	}
	public void setCycle(Double cycle) {
		this.cycle = cycle;
	}
	public Double getMoney() {
		return money;
	}
	public void setMoney(Double money) {
		this.money = money;
	}
	public String getUnit() {
		return unit;
	}
	public void setUnit(String unit) {
		this.unit = unit;
	}
	public String getMemo() {
		return memo;
	}
	public void setMemo(String memo) {
		this.memo = memo;
	}
	@ManyToOne(fetch = FetchType.LAZY)
	public User getOpuser() {
		return opuser;
	}
	public void setOpuser(User opuser) {
		this.opuser = opuser;
	}
	public Date getOpdate() {
		return opdate;
	}
	public void setOpdate(Date opdate) {
		this.opdate = opdate;
	}
}

